﻿using System;
using System.Collections.Generic;

using System.Text;

namespace HZ.DrugTrade.Model.Enum
{
    /// <summary>
    /// 枚举转换专用类
    /// </summary>
    public class EnumParse
    {
        #region 模块
        /// <summary>
        /// 根据模块名称获得模块枚举
        /// </summary>
        /// <param name="moduleName">Module名称</param>
        /// <returns></returns>
        public static Module? GetModule(string moduleName)
        {
            return (Module?)System.Enum.Parse(typeof(Module), moduleName,true);
        }

        /// <summary>
        /// 根据模块序号获得模块枚举
        /// </summary>
        /// <param name="module">Module序号</param>
        /// <returns></returns>
        public static Module? GetModule(int module)
        {
            return (Module?)module;
        }

        /// <summary>
        /// 根据模块枚举获得模块名称
        /// </summary>
        /// <param name="module">Module</param>
        /// <returns></returns>
        public static string GetModuleName(Module module)
        {
            return System.Enum.GetName(typeof(Module), module);
        } 
        #endregion

        #region 操作类型


        /// <summary>
        /// 根据操作名称获得操作枚举
        /// </summary>
        /// <param name="moduleName">OperateType名称</param>
        /// <returns></returns>
        public static OperateType? GetOperateType(string OperateName)
        {
            return (OperateType?)System.Enum.Parse(typeof(OperateType), OperateName, true);
        }

        /// <summary>
        /// 根据操作序号获得操作枚举
        /// </summary>
        /// <param name="module">OperateType序号</param>
        /// <returns></returns>
        public static OperateType? GetOperateType(int operate)
        {
            return (OperateType?)operate;
        }

        /// <summary>
        /// 根据操作枚举获得操作名称
        /// </summary>
        /// <param name="module">OperateType</param>
        /// <returns></returns>
        public static string GetOperateName(OperateType operate)
        {
            return System.Enum.GetName(typeof(OperateType), operate);
        } 

        #endregion

        #region 企业类型
        /// <summary>
        /// 根据企业类型名称获得企业类型枚举
        /// </summary>
        /// <param name="companyTypeName">企业类型名称</param>
        /// <returns></returns>
        public static EnumCompanyType? GetCompanyType(string companyTypeName)
        {
            return (EnumCompanyType?)System.Enum.Parse(typeof(EnumCompanyType), companyTypeName);
        }

        /// <summary>
        /// 根据企业类型枚举获得企业类型名称
        /// </summary>
        /// <param name="companyType">企业类型枚举</param>
        /// <returns></returns>
        public static string GetCompanyType(EnumCompanyType companyType)
        {
            return System.Enum.GetName(typeof(EnumCompanyType), companyType);
        }
        #endregion


    }
}
